package com.xr.controller;

import com.xr.exception.CustomException;
import com.xr.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class BaseExceptionAdvice {
    // 自定义的异常处理
    @ExceptionHandler(CustomException.class)
    public Result handleCustomException(CustomException ex){
        return new Result(false,ex.getMessage());
    }

    //所有未知的异常
    public Result handleException(CustomException ex){
        return new Result(false,"发生未知错误，操作失败，请联系管理员");
    }

}
